import ArrayStack from "./01_ArrayStack";

function decimalToBinary(decimal: number): string {
  const stack = new ArrayStack();
  let rem = 0;
  while (decimal > 0) {
    rem = Math.floor(decimal % 2);
    decimal = Math.floor(decimal / 2);
    stack.push(rem);
  }

  let str = "";
  while (stack.size() !== 0) {
    str += stack.pop();
  }

  return str;
}

console.log(decimalToBinary(10));
